const path=require('path')

//在内存中，根据指定的额模板页面，生成一份内存中的首页，同时自动把打包好的
//bundle注入到页面底部
//如果要配置插件，需要在导出的对象中挂在一个plugins节点
const htmlWebpackPlugin=require('html-webpack-plugin')


module.exports={
	entry:path.join(__dirname,'./src/main.js'),
	output:{
		path:path.join(__dirname,'./dist'),
		filename:'bundle.js'
	},
	plugins:[
	  new htmlWebpackPlugin({
	  	template:path.join(__dirname,'./src/index.html'),
	  	filename:'index.html'
	  })
	],
	module:{
		rules:[
		{test:/\.css/,use:['style-loader','css-loader']},
		{test:/\.less/,use:['style-loader','css-loader','less-loader']},
		{test:/\.scss/,use:['style-loader','css-loader','sass-loader']},
		 { test: /\.(jpg|png|gif|bmp|jpeg)$/, use: 'url-loader?limit=3691&name=[hash:8]-[name].[ext]' },
		 {test:/\.(ttf|eot|svg|woff|woff2)$/,use:'url-loader'},
		 {test:/\.js$/,use:'babel-loader',exclude:/node_modules/},
		 // {test:/\.js$/,use:'babel-loader',exclude:/node_modules/}
		 //用Babel转换Es6高级语法到低级语法
		 {test:/\.vue$/,use:'vue-loader'},
		]
	},
	resolve:{
		alias:{
			'vue$':'vue/dist/vue.js'
		}
	},

}